package com.example.hrms.service;


import com.example.hrms.entity.*;
import com.example.hrms.mapper.UserMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
//简单粗暴的解释就是：
// @Service告诉系统此类以及已经注册了，你可以用@Autowired来new出对象来。
// 系统帮你在用到的地方自动new了一个UserService的对象，名字叫userService
// 等同于UserService userService = new UserService();
// 配合@Autowired使用，@Autowired用来new，
public class UserService {
    @Autowired
    private UserMapper userMapper;//通过 Autowired注解实例化对象userMapper；
    public User checkUserLogin(String username, String password){
        return userMapper.checkUserLogin(username,password);
    }
    public List<StaffPersonalInfo1> getAllStaffPersonalInfo(){
        return userMapper.getAllStaffPersonalInfo();
    }
    public List<PersonnelMatterInfo> getAllPersonenlMatterlInfo(){
        return userMapper.getAllPersonenlMatterlInfo();
    }
    public int updatePersonalInfo(int piid,String name,int sex,String phone,String address,String birthday){
        return userMapper.updatePersonalInfo(piid,name,sex,phone,address,birthday);
    }
    public int deletePersonalInfo(int piid){
        return userMapper.deletePersonalInfo(piid);
    }
    public int updatePersonnelMatter(int pmid,String joinTime,String departmen,String position,int salary,int isRegular){
        return userMapper.updatePersonnelMatter(pmid,joinTime,departmen,position,salary,isRegular);
    }
    public User checkUsername(String uesrname){
        return userMapper.checkUsername(uesrname);
    }
    public int addUser(User user){
        return userMapper.addUser(user);
    }
    public int addPersonalInfo(StaffPersonalInfo1 NewPersonalInfo){
        return userMapper.addPersonalInfo(NewPersonalInfo);
    }
    public int addPersonnelMatter(StaffPersonnelMatter NewPersonnelInfo){
        return userMapper.addPersonnelMatter(NewPersonnelInfo);
    }
    public List<StaffAccountInfo> getAllStaffAccountInfo(){
        return userMapper.getAllStaffAccountInfo();
    }
    public int updateUser(int uid, String username,String password,Timestamp modify){
        return userMapper.updateUser(uid,username,password,modify);
    }
    public int deleteUser(int uid){
        return userMapper.deleteUser(uid);
    }
    public List<RPInfo> getAllRPInfo(){
        return userMapper.getAllRPInfo();
    }
    public int addStaffRP(int uid,String type,String detail,String time){
        return userMapper.addStaffRP(uid,type,detail,time);
    }
    public User checkStaffID(int uid){
        return userMapper.checkStaffID(uid);
    }
    public int deleteRPInfo(int rpid){
        return userMapper.deleteRPInfo(rpid);
    }
    public int updateStaffRP(int rpid,String type,String detail,String RPTime){
        return userMapper.updateStaffRP(rpid,type,detail,RPTime);
    }
    public List<RoadInfo> getAllRoadInfo(){
        return userMapper.getAllRoadInfo();
    }
    public  List<DriverInfo> getAllDriver(){
        return userMapper.getAllDriver();
    }
    public List<Road_Info> getAllRoad(){
        return userMapper.getAllRoad();
    }
    public int addDriver(int rid,int uid,String note){
        return userMapper.addDriver(rid,uid,note);
    }
    public int findDAByRidUid(int rid,int uid){
        if(userMapper.findDAByRidUid(rid,uid)==null){
            return 0;
        }
        else {
            return userMapper.findDAByRidUid(rid,uid);
        }

    }
    public int findDAByUid(int uid){
        if(userMapper.findDAByUid(uid)==null){
            return 0;
        }
        else {
            return userMapper.findDAByUid(uid);
        }

    }
    public int findRoadByRoadNumber(String roadNumber){
        if(userMapper.findRoadByRoadNumber(roadNumber)==null){
            return 0;
        }else {
            return userMapper.findRoadByRoadNumber(roadNumber);
        }
    }
    public int addRoad(String roadNumber,String line,Timestamp createTime){
        return userMapper.addRoad(roadNumber,line,createTime);
    }
    public int deleteAssign(int uid,int rid){
        return userMapper.deleteAssign(uid,rid);
    }
    public int deleteRoad(int rid){
        return userMapper.deleteRoad(rid);
    }
    public int updateRoadInfo(int rid,String roadUnmber,String line,Timestamp t){
        return userMapper.updateRoadInfo(rid,roadUnmber,line,t);
    }
    public int updateDriverAssign(int ruid,int uid,String note){
        return userMapper.updateDriverAssign(ruid,uid,note);
    }
    public StaffPersonalInfo1 getStaffPersonalInfoByUsername(String username){
        return userMapper.getStaffPersonalInfoByUsername(username);
    }

    public int updatePwdByUsername(String username,String  pwd){
        return userMapper.updatePwdByUsername(username, pwd);
    }
    public   StaffInfo getStaffInfo(int uid){return userMapper.getStaffInfo(uid);}

    public List<StaffRPInfo> getRPInfoByUid(int uid){
        return userMapper.getRPInfoByUid(uid);
    }
    public int addStaffCL(int uid,String CLtype,String startTime,String endTime,Timestamp signUpTime,String CLDetail){
        return userMapper.addStaffCL(uid,CLtype,startTime,endTime,signUpTime,CLDetail);
    }
    public List<StaffCL> getCLListByUid(int uid){
        return userMapper.getCLListByUid(uid);
    }

    public   List<StaffCL> checkCLTime(String start,String end,int uid){
        return userMapper.checkCLTime(start,end,uid);
    }

    public int deleteStaffCL(int clid){
        return userMapper.deleteStaffCL(clid);
    }
    public List<CLInfo> getAllCLInfo(){
        return userMapper.getAllCLInfo();
    }
    public int overTimeCheck(){
        return userMapper.overTimeCheck();
    }

    public int passCL(int clid){
        return userMapper.passCL(clid);
    }
    public int refuseCL(int clid){
        return userMapper.refuseCL(clid);
    }
    public DriverAssignInfo getDriverInfo(int uid){
        return userMapper.getDriverInfo(uid);
    }

}
